<template>
	<view>
		<view class="buy-wrap">
			<view class="buy-icon">
				<block v-for="(item,index) in list" :key="index">
					<view class="buy-icon-text">
						<image :src="item.icon" mode=""></image>
						<text>{{item.uname}}</text>
					</view>
				</block>
			</view>
			<view class="buy-text">
				<text class="buy-text-btn1" @click="buycar">加入购物车</text>
				<text class="buy-text-btn2" @click="buynow">立即购买</text>
				
			</view>
		</view>
		<!-- 未登录提示 -->
		<!-- <load v-show="shoes"></load> -->
		<!-- 反馈组件 -->
		<HMmessages ref="HMmessages" @complete="HMmessages = $refs.HMmessages" @clickMessage="clickMessage"></HMmessages>
		
		
	</view>
</template>

<script>
	//顶部消息提示插件
	 import HMmessages from "@/components/HM-messages/HM-messages.vue"
	import load from '../../../element/titol.vue'
	export default{
		props:{
			getdata:Array
		},
		components:{
			load,
			HMmessages
		},
		data(){
			return{
				list:[
					{
						"icon":'../../../static/tab/dianpu.png',
						"uname":"店铺"
					},
					{
						"icon":'../../../static/tab/kefu.png',
						"uname":"客服"
					},
					{
						"icon":'../../../static/tab/car.png',
						"uname":"购物车"
					}
				]
			}
		},
		methods:{
			//加入购物车
			buycar(){
				let buycar = '加购物车'
				this.ifUser(buycar)
			},
			//立即下单
			buynow(){
				let buynow = '立即买'
				this.ifUser(buynow)
			},
			//判断用户是否登录
			ifUser(solt){
				console.log(solt)
				const db = wx.cloud.database() 
				db.collection('users').get().then(res=>{
					if(res.data.length==0){
						console.log('没有登录')
						// this.shoes = true
						this.HMmessages.show("请先去个人中心登录",{icon:'fail',fontColor:'#000000',background:'#f40000',iconColor:'#000000'})
					}else{
						console.log('已经登录')
						wx.navigateTo({
							url:'../buyGoods/buyGoods'
						})
					}
				})
			}
			
		}
	}
</script>

<style lang="scss">
	.buy-wrap{
		width: 100%;
		background-color: #ffffff;
		position: fixed;
		bottom: 0;
		left: 0;
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding: 8upx 10upx;
		.buy-icon{
			display: flex;
			justify-content: start;
			align-items: center;
			image{
				width: 45upx;
				height: 45upx;
			}
			.buy-icon-text{
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				margin: 0 20upx;
				padding: 0 10upx;
				box-sizing: border-box;
				text{
					color: #acacac;
					font-size: 20upx;
				}
			}
		}
		.buy-text{
			display: flex;
			justify-content: center;
			align-items: center;
			box-sizing: border-box;
			.buy-text-btn1{
				background-color: #f9ac11;
				border-radius-left:50upx ;
				padding: 20upx 40upx;
				box-sizing: border-box;
				border-top-left-radius: 50upx;
				border-bottom-left-radius: 50upx;
				font-size: 25upx;
				color:#ffffff;
			}
			.buy-text-btn2{
				background-color: #ee4116;
				border-start-end-radius:50upx ;
				padding: 20upx 40upx;
				box-sizing: border-box;
				border-top-right-radius: 50upx;
				border-bottom-right-radius: 50upx;
				font-size: 25upx;
				color:#ffffff;
			}
		}
	}
</style>
